package com.Shoping.util;

import java.io.File;
import java.util.UUID;

public class UploadUtils {
    public static String getFileName(String fileName){
        return UUID.randomUUID().toString().replaceAll("-","")+"_"+fileName;
    }

    public static String getUploadPath(String fileName,String uploadPath){
        int hashCode = fileName.hashCode();
        int path1 = hashCode&15;
        int path2 = (hashCode>>4)&15;
        String newUploadPath = uploadPath+"\\"+path1+"\\"+path2;
        File file = new File(newUploadPath);
        if(!file.exists()){
            file.mkdirs();
        }
        return newUploadPath;
    }
}
